/**
*      author: Y_Yao
*      created: 2024-10-31 21:10:03
**/

#include<bits/stdc++.h>

using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;

void solve()
{
    string str,l,d;
    cin >> str;
    int k = 0;
    for(k = 0;k < str.size();k++)
    {
        if(str[k] == '@') break;
    }
    if(k == str.size())
    {
        cout << "No" << endl;
        return;
    }

    l = str.substr(0,k);
    d = str.substr(k + 1);

    //cout << l << " " << d << endl;
    if(l.size() < 1 || l.size() > 64)
    {
        cout << "No" << endl;
        return;
    }
    for(int i = 0;i < l.size();i++)
    {
        if(l[i] >= '0' && l[i] <= '9') continue;
        else if(l[i] >= 65 && l[i] <= 90) continue;
        else if(l[i] >= 65 + 32 && l[i] <= 90 + 32) continue;
        else if(l[i] == '.')
        {
            if(i == 0 || i == l.size() - 1)
            {
                cout << "No" << endl;
                return;
            }            
        }
        else
        {
            cout << "No" << endl;
            return;
        }
    }


    if(d.size() < 1 || d.size() > 255)
    {
        cout << "No" << endl;
        return;
    }
    for(int i = 0;i < d.size();i++)
    {
        if(d[i] >= '0' && d[i] <= '9') continue;
        else if(d[i] >= 65 && d[i] <= 90) continue;
        else if(d[i] >= 65 + 32 && d[i] <= 90 + 32) continue;
        else if(d[i] == '.' || d[i] == '-')
        {
            if(i == 0 || i == d.size() - 1)
            {
                cout << "No" << endl;
                return;
            }
        }
        else
        {
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}